package com.iuie.ns.system.dao.user.impl;

import java.io.Serializable;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.iuie.ns.frame.persistence.dao.impl.GenericDaoImpl;
import com.iuie.ns.system.dao.user.ISysUserDao;
import com.iuie.ns.system.vo.user.SysUserVO;

/**
 * 系统用户Dao实现类
 * @author lj
 * @createTime 2017年1月2日 下午7:19:51
 */
@Repository("userDao")
public class SysUserDaoImpl extends GenericDaoImpl<SysUserVO> implements ISysUserDao {

	@Override
	public SysUserVO findByIdWithRoles(Serializable id) {
		String hql = "FROM SysUserVO u left join fetch u.roles where u.userId=:userId";
        Query query = getCurrentSession().createQuery(hql);
        query.setString("userId", (String)id);
        SysUserVO user = (SysUserVO) query.uniqueResult();
		return user;
	}


}
